<route lang="json5" type="page">
{
  style: {
    navigationBarTitleText: '',
  },
}
</route>

<template>
  <div class="agreement-page" v-if="pageData.id">
    <rich-text :nodes="pageData.content" />
  </div>
  <Seat v-else :loading="loading" />
</template>

<script lang="ts" setup>
import { useUserStore } from '@/store/index'

defineOptions({ name: 'LoginModal' })

const userStore = useUserStore()
userStore.setShowModal(false) // 关闭协议

const loading = ref(false)

onUnload(() => {
  // 未登录状态从当前页面退出，显示登录框
  if (!userStore.isLogged) {
    userStore.setShowModal(true) // 退出时打开协议
  }
})

const pageData = ref({})

onLoad((query) => {
  loading.value = true
  http
    .get('/agreement-app/open/detail', {
      code: query.type,
    })
    .then((res: any) => {
      if (res) {
        pageData.value = res
        uni.setNavigationBarTitle({ title: res.name })
      }
    })
    .finally(() => {
      loading.value = false
    })
})
</script>

<style lang="scss" scoped>
.agreement-page {
  padding: 30rpx;
}
</style>
